{% extends "dissemin/details.html" %}

{% load author %}
{% load i18n %}
{% load statuses %}
{% load domain %}
{% load bootstrap_pagination %}
{% load staticfiles %}

{% block headTitle %}
{{ publisher }}
{% endblock %}

{% block bodyTitle %}
{{ publisher }}
{% endblock %}

{% block jsScript %}
   {% if request.user.is_superuser %}
   var current_status = '{{ publisher.oa_status }}';
    function changeOaStatus(new_status) {
       $.post('/ajax/change-publisher-status',
       'pk={{ publisher.pk }}&amp;csrfmiddlewaretoken={{csrf_token}}&amp;status='+new_status
       ).done( function () {
         $('#criterion-'+current_status).toggleClass('selectedCriterion unselectedCriterion');
         $('#criterion-'+new_status).toggleClass('selectedCriterion unselectedCriterion');
         current_status = new_status;
       }).fail(
       function(message) {
       console.log(message);
         alert('Error: '+message);
       });
    }
    {% endif %}
  $(function(){
  $('.helpPopover').popover({trigger: "hover"});
  });
{% endblock %}

{% block details %}
<span class="detailsTitle">{% trans "Publisher" %}</span>
<div class="detailsContent">
<p id="detail-name">{{ publisher.name }}</p>
{% if publisher.url %}
<p>
    <span class="glyphicon glyphicon-home"></span>
    <a href="{{ publisher.url }}">{{ publisher.url|domain }}</a>
</p>
{% endif %}

{% if not request.user.is_superuser %}
    <div class="unselectedCriterion">
        <div class="pubLogo"><div class="pubLogoPic-{{ publisher.oa_status }}"></div></div>
        <div class="criterionItem">{{ publisher.oa_status |explain_oa_status }}</div>
    </div>
{% endif %}

<p class="sherpaAcknowledgement">{% trans "Policy data provided by" %}<br />
<a href="http://www.sherpa.ac.uk/romeo/"><img src="{% static "img/sherpa-romeo.gif" %}" width="210" alt="SHERPA/RoMEO" /></a><br/>
<a
href="http://www.sherpa.ac.uk/romeo/feedback.php?la=en&amp;fIDnum=%7C&amp;mode=simple&amp;type=jpnew"
>{% trans "Report any error to them" %}</a></p>
<p>

{% if request.user.is_superuser %}
</div>
<span class="detailsTitle">{% trans "Policy" %}</span>
<div class="detailsContent">
 <br />
{% for st in oa_status_choices %}
<div class="{% if st.0 == publisher.oa_status %}selectedCriterion{% else %}unselectedCriterion{% endif %}" id="criterion-{{ st.0 }}">
    <div class="pubLogo"><div class="pubLogoPic-{{ st.0 }}">
            <a href="javascript:changeOaStatus('{{ st.0 }}');" class="filldiv"></a>
    </div></div>
    <div class="criterionItem">
    <a href="javascript:changeOaStatus('{{ st.0 }}');">{{ st.1 }}</a>
    </div>
</div>
{% endfor %}

{% endif %}

</div>
{% endblock %}

{% block lists %}
{% with publisher.preprint as policy %}
<div class="publisher-policy">
{% include "publishers/detailsPolicy.html" with mode="none" %}
</div>
{% endwith %}
{% if publisher.has_conditions %}
    <h4>{% trans "Conditions" %}</h4>
    <ul>
    {% for condition in publisher.publishercondition_set.all %}
        <li>{{ condition|striptags }}</li>
    {% endfor %}
    </ul>
{% endif %}
{% if publisher.has_copyrightlinks %}
    <h4>{% trans "Policy details" %}</h4>
    <ul>
        {% for link in publisher.publishercopyrightlink_set.all %}
            <li><a href="{{ link.url }}">{{ link.text }}</a></li>
        {% endfor %}
    </ul>
{% endif %}

{% if request.user.is_superuser %}
<h4>{% trans "Publications" %}</h4>
<ul>
    <li><a href="{% url 'publisher-papers' publisher.id publisher.slug %}">
        {% blocktrans trimmed with publisher=publisher.name %}
        All papers published by {{ publisher }}
        {% endblocktrans %}
    </a></li>
</ul>
<h4>{% trans "Journals" %}</h4>
<p>{% trans "Only journals with papers written by our users are listed." %}</p>
{% if journals.paginator.num_pages > 1 %}
 <div class="searchPages">{% bootstrap_paginate journals range=10 %}</div>
 {% endif %}
<ul class="withoutTriangles">
    {% for journal in journals %}
        <li><a href="{% url 'journal' journal.id %}">{{ journal }}</a>
           <span class="numPapers">
               {% blocktrans trimmed count num_total=journal.stats.num_tot %}
               ({{ num_total }} paper)
               {% plural %}
               ({{ num_total }} papers)
               {% endblocktrans %}
           </span></li>
    {% empty %}
    <p>{% trans "None." %}</p>
    {% endfor %}
</ul>
{% endif %}
{% endblock %}
